package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Goods;

public class GoodsSqlProvider {

    public String insertSelective(Goods record) {
        BEGIN();
        INSERT_INTO("st_goods");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            VALUES("picture", "#{picture,jdbcType=VARCHAR}");
        }
        
        if (record.getPrice() != null) {
            VALUES("price", "#{price,jdbcType=DOUBLE}");
        }
        
        if (record.getNumber() != null) {
            VALUES("number", "#{number,jdbcType=INTEGER}");
        }
        
        if (record.getSurplus_number() != null) {
            VALUES("surplus_number", "#{surplus_number,jdbcType=INTEGER}");
        }
        
        if (record.getExchange_note() != null) {
            VALUES("exchange_note", "#{exchange_note,jdbcType=VARCHAR}");
        }
        
        if (record.getExchange_point() != null) {
            VALUES("exchange_point", "#{exchange_point,jdbcType=INTEGER}");
        }
        
        if (record.getStart_time() != null) {
            VALUES("start_time", "#{start_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnd_time() != null) {
            VALUES("end_time", "#{end_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getState() != null) {
            VALUES("state", "#{state,jdbcType=TINYINT}");
        }
        
        if (record.getBcid() != null) {
            VALUES("bcid", "#{bcid,jdbcType=INTEGER}");
        }
        
        if (record.getSpecifications() != null) {
            VALUES("specifications", "#{specifications,jdbcType=VARCHAR}");
        }
        
        if (record.getDisount() != null) {
            VALUES("disount", "#{disount,jdbcType=VARCHAR}");
        }
        
        if (record.getRemarks() != null) {
            VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getGo_type() != null) {
            VALUES("go_type", "#{go_type,jdbcType=VARCHAR}");
        }
        
        if (record.getSale_time() != null) {
            VALUES("sale_time", "#{sale_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getList_time() != null) {
            VALUES("list_time", "#{list_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getList_name() != null) {
            VALUES("list_name", "#{list_name,jdbcType=VARCHAR}");
        }
        
        if (record.getPurchase_price() != null) {
            VALUES("purchase_price", "#{purchase_price,jdbcType=VARCHAR}");
        }
        
        if (record.getSuid() != null) {
            VALUES("suid", "#{suid,jdbcType=INTEGER}");
        }
        
        if (record.getCompany() != null) {
            VALUES("company", "#{company,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Goods record) {
        BEGIN();
        UPDATE("st_goods");
        
        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            SET("picture = #{picture,jdbcType=VARCHAR}");
        }
        
        if (record.getPrice() != null) {
            SET("price = #{price,jdbcType=DOUBLE}");
        }
        
        if (record.getNumber() != null) {
            SET("number = #{number,jdbcType=INTEGER}");
        }
        
        if (record.getSurplus_number() != null) {
            SET("surplus_number = #{surplus_number,jdbcType=INTEGER}");
        }
        
        if (record.getExchange_note() != null) {
            SET("exchange_note = #{exchange_note,jdbcType=VARCHAR}");
        }
        
        if (record.getExchange_point() != null) {
            SET("exchange_point = #{exchange_point,jdbcType=INTEGER}");
        }
        
        if (record.getStart_time() != null) {
            SET("start_time = #{start_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnd_time() != null) {
            SET("end_time = #{end_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getState() != null) {
            SET("state = #{state,jdbcType=TINYINT}");
        }
        
        if (record.getBcid() != null) {
            SET("bcid = #{bcid,jdbcType=INTEGER}");
        }
        
        if (record.getSpecifications() != null) {
            SET("specifications = #{specifications,jdbcType=VARCHAR}");
        }
        
        if (record.getDisount() != null) {
            SET("disount = #{disount,jdbcType=VARCHAR}");
        }
        
        if (record.getRemarks() != null) {
            SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        
        if (record.getGo_type() != null) {
            SET("go_type = #{go_type,jdbcType=VARCHAR}");
        }
        
        if (record.getSale_time() != null) {
            SET("sale_time = #{sale_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getList_time() != null) {
            SET("list_time = #{list_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getList_name() != null) {
            SET("list_name = #{list_name,jdbcType=VARCHAR}");
        }
        
        if (record.getPurchase_price() != null) {
            SET("purchase_price = #{purchase_price,jdbcType=VARCHAR}");
        }
        
        if (record.getSuid() != null) {
            SET("suid = #{suid,jdbcType=INTEGER}");
        }
        
        if (record.getCompany() != null) {
            SET("company = #{company,jdbcType=VARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}